<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set value="<%=request.getContextPath()%>" var="ctx"></c:set>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="keywords" content="关键字台">
    <meta name="description" content="描述"> 
    <link href="${ctx}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/animate.css" rel="stylesheet">
    <link href="${ctx}/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="${ctx}/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctx}/css/plugins/toastr/toastr.min.css">
	<title>礼品兑奖申请</title>


</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <div class="row">
                           <div class="col-sm-12">
                                <h3>礼品兑奖申请</h3>
                           </div>
                        </div>
                    </div>
  
	             <div class="ibox-content">
					<table class="table table-striped table-bordered table-hover dataTables-example text-center" id='tb'>
						<thead>
							<tr>
								<th class="text-center">序号</th>
								<th class="text-center">微信昵称</th>
								<th class="text-center">头像</th>
								<th class="text-center">姓名</th>
								<th class="text-center">手机号</th>
								<th class="text-center">礼品</th>
								<th class="text-center">兑换日期</th>
								<th class="text-center">收件地址</th>
								<th class="text-center">操作</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
				</div>
			

				</div>
			</div>
		</div>
	</div>

	<div class="modal inmodal in" id="sendGift_modal" tabindex="-1" role="dialog"
		aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content animated fadeIn">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">×</span><span class="sr-only">Close</span>
					</button>
					<h2 class="modal-title">发货</h2>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="sendGift" method="POST">
						<input type="hidden" name="id" id="sendGiftId">
						<div class="form-group">
							<label class="col-lg-3 control-label">物流公司：</label>
							<div class="col-lg-8">
								<input type="text" class="form-control" name="logisticsName"  maxlength="20">
							</div>
						</div>
						<div class="form-group">
							<label class="col-lg-3 control-label">物流单号：</label>
							<div class="col-lg-8">
								<input type="text" class="form-control" name="logisticsNum"  maxlength="50">
							</div>
						</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" data-flg="0">确认</button>
			</div>
		</div>
	</div>
	</div>
	
		<!-- 全局js -->
    <script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
	<!-- 自定义js -->
	<script src="${ctx}/js/plugins/toastr/toastr.min.js"></script>
	<script src="${ctx}/js/jquery.validate.min.js"></script>
	<script src="${ctx}/js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="${ctx}/js/plugins/dataTables/dataTables.bootstrap.js"></script>
	<script type="text/javascript">
	$(function() {
			var table = $('#tb').DataTable({
				"bPaginate":true,//翻页功能
				"iDisplayLength": 10,//每页显示的行数
				"bSort":false,//排序功能
				'bLengthChange': false, //是否允许用户自定义每页显示条数。
				"bProcessing": true, // 是否显示取数据时的那个等待提示
                "bServerSide": true,//这个用来指明是通过服务端来取数据
                "sAjaxSource": "${ctx}/awardManage/djApply",//这个是请求的地址
                "fnServerData": retrieveData, // 获取数据的处理函数
				"aoColumns": [
										{ "sClass": "center","bSearchable": true,"aTargets" : [0],
										  "mRender": function(data, type, full) {
			                                  return full.seq;} 
										},
										{ "sClass": "center","mRender": function(data, type, full) {
                                            if(full.nickName == null){
                                                return '';
                                            }else{
                                                return full.nickName;
                                            }
                                         }},
                                        { "sClass": "center","mRender": function(data, type, full) {
                                            if(full.headPic == null){
                                                return '';
                                            }else{
                                                return '<img alt="image" class="img-circle" src='+full.headPic+' style="width:50px;"/>';
                                            }
                                        }},
										{ "sClass": "center", "mRender": function(data, type, full) {
					 						if(full.contactName == null){
												return '';
											}else{
												return full.contactName;
											}
										 }},
										{ "sClass": "center","mRender": function(data, type, full) {
					 						if(full.mobile == null){
												return '';
											}else{
												return full.mobile;
											}
										 }},
										{ "sClass": "center","mRender": function(data, type, full) {
											if(full.giftName == null){
												return '';
											}else{
												return full.giftName;
											}
										}},
										{ "sClass": "center", "mRender": function(data, type, full) {
											if(full.updatetime == null){
												return '';
											}else{
												return full.updatetime;
											}		
										}},
										{ "sClass": "center", "mRender": function(data, type, full) {
											if(full.address == null){
												return '';
											}else{
												return full.address;
											}
										}},
										{ "sClass": "center", "mRender": function(data, type, full) {
											if(full.id == null){
												return '';
											}else{
												return "<button type='button' class='btn btn-primary'  onclick='modalShow("+full.id+");return false;' >发货</button>";
											}
										}}
									]
			});
		
		//更新礼品添加表单验证
		$("#sendGift").validate({
			rules:{
				logisticsName:{
					required:true,
					maxlength:20
				},
				logisticsNum:{
					required:true,
				}				
			},
			messages: {
				logisticsName: {
	                required: "请输入物流公司名称",
	                maxlength:"物流公司名称不能超过20个字符"
	            },
	            logisticsNum: {
	                required: "请输入物流单号"
	            }
			}
		});
		
		$("#sendGift_modal").on("click", "button", function(){
			if($(this).data('flg')=="0"){
				var path = "addLogisticsInformation";  
				if($("#sendGift").valid()){
					$('#sendGift').attr("action", path).submit();
					$('#sendGift_modal').modal("hide");
				}
			}
		});
		
		
	});
	
	  //分页方法
    function retrieveData(sSource,aoData, fnCallback){
        var dataArr = eval("["+JSON.stringify(aoData)+"]");
        $.ajax({
            url : sSource, //这个就是请求地址对应sAjaxSource
            data : {"aoData":JSON.stringify(dataArr)},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
            type : 'post',
            dataType : 'json',
            async : false,
            success : function(result) {
                fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
            },
            error : function(msg) {
            }
        });
    }
		  
	function modalShow(id){
	    $("#sendGiftId").attr("value",id);
		$('#sendGift_modal').modal();
	}
  
</script>
</body>
</html>